<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--<%@ page import="java.io.*,java.util.*,javax.servlet.*" %>
<%
    Boolean isLoggedIn = (Boolean) session.getAttribute("isLoggedIn");
    if (isLoggedIn == null || !isLoggedIn) {
        response.sendRedirect("login.jsp"); // 如果用户未登录，重定向到登录页面
        return;
    }
%>--%>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发布新闻 - 新闻发布系统</title>
    <link rel="stylesheet" href="css/style.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
    <style>
        .publish-container {
            max-width: 800px;
            margin: 2rem auto;
            padding: 2rem;
            background-color: var(--card-bg);
            border-radius: 8px;
            box-shadow: 0 4px 6px var(--shadow-color);
            transition: all var(--transition-speed);
        }

        .publish-header {
            text-align: center;
            margin-bottom: 2rem;
        }

        .publish-header h1 {
            color: var(--text-color);
            font-size: 2rem;
            margin-bottom: 0.5rem;
        }

        .publish-header p {
            color: var(--text-light);
        }

        .publish-form .form-group {
            margin-bottom: 1.5rem;
        }

        .publish-form .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--text-color);
            font-weight: 500;
        }

        .publish-form .form-control {
            width: 100%;
            padding: 0.8rem;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background-color: var(--card-bg);
            color: var(--text-color);
            transition: all var(--transition-speed);
        }

        .publish-form .form-control:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
        }

        .publish-form textarea.form-control {
            min-height: 200px;
            resize: vertical;
        }

        .publish-form .btn-group {
            display: flex;
            gap: 1rem;
            margin-top: 2rem;
        }

        .publish-form .btn {
            flex: 1;
            padding: 1rem;
            font-size: 1rem;
            font-weight: 500;
            transition: all var(--transition-speed);
        }

        .publish-form .btn-secondary {
            background-color: var(--secondary-color);
        }

        .publish-form .btn-secondary:hover {
            background-color: #27ae60;
        }

        .navbar-actions {
            display: flex;
            align-items: center;
            gap: 1rem;
        }
    </style>
</head>
<body>
    <header>
        <nav class="navbar">
            <div class="logo">
                <h1>新闻发布系统</h1>
            </div>
            <div class="navbar-actions">
                <ul class="nav-links">
                    <li><a href="index.jsp"><i class="fas fa-newspaper"></i> 查看新闻</a></li>
                    <li><a href="publish.jsp" class="active"><i class="fas fa-edit"></i> 发布新闻</a></li>
                    <li><a href="manage.jsp"><i class="fas fa-cog"></i> 新闻管理</a></li>
                    <li><a href="login.jsp"><i class="fas fa-user"></i> 管理员登录</a></li>
                    <li><a href="contact.jsp"><i class="fas fa-envelope"></i> 联系管理员</a></li>
                </ul>
                <div class="clock-container">
                    <i class="fas fa-clock"></i>
                    <div class="clock-time" id="clockTime">00:00:00</div>
                    <div class="clock-date" id="clockDate">2024-03-15</div>
                </div>
                <button class="theme-toggle" id="themeToggle" title="切换主题">
                    <i class="fas fa-moon"></i>
                </button>
            </div>
        </nav>
    </header>

    <main>
        <div class="publish-container">
            <div class="publish-header">
                <h1>发布新闻</h1>
                <p>创建新的新闻文章</p>
            </div>
            <form class="publish-form" id="publishForm">
                <div class="form-group">
                    <label for="title">标题</label>
                    <input type="text" id="title" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="category">分类</label>
                    <select id="category" class="form-control" required>
                        <option value="">请选择分类</option>
                        <option value="technology">科技</option>
                        <option value="business">商业</option>
                        <option value="sports">体育</option>
                        <option value="entertainment">娱乐</option>
                        <option value="health">健康</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="content">内容</label>
                    <textarea id="content" class="form-control" required></textarea>
                </div>
                <div class="form-group">
                    <label for="image">封面图片</label>
                    <input type="file" id="image" class="form-control" accept="image/*">
                </div>
                <div class="btn-group">
                    <button type="submit" class="btn">发布</button>
                    <button type="button" class="btn btn-secondary" onclick="window.location.href='index.html'">取消</button>
                </div>
            </form>
        </div>
    </main>

    <footer>
        <p>&copy; 2024 新闻发布系统 版权所有</p>
    </footer>

    <script>
        // 时钟功能
        function updateClock() {
            const now = new Date();
            const timeElement = document.getElementById('clockTime');
            const dateElement = document.getElementById('clockDate');
            
            // 更新时间
            const hours = String(now.getHours()).padStart(2, '0');
            const minutes = String(now.getMinutes()).padStart(2, '0');
            const seconds = String(now.getSeconds()).padStart(2, '0');
            timeElement.textContent = `${hours}:${minutes}:${seconds}`;
            
            // 更新日期
            const year = now.getFullYear();
            const month = String(now.getMonth() + 1).padStart(2, '0');
            const day = String(now.getDate()).padStart(2, '0');
            dateElement.textContent = `${year}-${month}-${day}`;
        }

        // 初始化时钟并每秒更新
        updateClock();
        setInterval(updateClock, 1000);

        // 主题切换功能
        const themeToggle = document.getElementById('themeToggle');
        const themeIcon = themeToggle.querySelector('i');
        
        // 检查本地存储中的主题设置
        const currentTheme = localStorage.getItem('theme') || 'light';
        document.documentElement.setAttribute('data-theme', currentTheme);
        updateThemeIcon(currentTheme);

        themeToggle.addEventListener('click', () => {
            const newTheme = document.documentElement.getAttribute('data-theme') === 'light' ? 'dark' : 'light';
            document.documentElement.setAttribute('data-theme', newTheme);
            localStorage.setItem('theme', newTheme);
            updateThemeIcon(newTheme);
        });

        function updateThemeIcon(theme) {
            themeIcon.className = theme === 'light' ? 'fas fa-moon' : 'fas fa-sun';
        }

        // 发布表单处理
        document.getElementById('publishForm').addEventListener('submit', function(e) {
            e.preventDefault();
            const title = document.getElementById('title').value;
            const category = document.getElementById('category').value;
            const content = document.getElementById('content').value;
            const image = document.getElementById('image').files[0];
            
            // 这里添加发布逻辑
            console.log('发布新闻:', { title, category, content, image });
            // 发布成功后跳转到新闻列表
            window.location.href = 'index.html';
        });
    </script>
</body>
</html> 